C++11之Lambda与bind

Lambda语法和stl::bind 都是语法糖,但不得不说它们的作用很出色: 1. 更方便的定义匿名函数 2. 更简洁的代码逻辑 3. 更安全的私有函数 这称之为closure,即闭包. Lambda 表达式语法有如下五种形式: [capture](parameters) mutable throw() ->return_type {body} [capture](parameters) mutable ->return_type {body} [capture](parameters) ->return_type {body} [capture](parameters) {body} [capture] {body} capture []用于标识一个lambda的开始,其中可以存在零个或多个捕获参数,用逗号分隔.并且只允许以下两种标识符表示: & 引用值 = 拷贝值 对于参数的形式可以有: 1. … Continue reading C++11之Lambda与bind